<template>
    <div v-if="loading" class="loading">
        <div class="loading_icon">
            <img src="@/assets/applogo.png" />
            <div>加载中...</div>
        </div>
    </div>
</template>
 
<script setup lang="ts">
import { ref } from 'vue'

const loading = ref(false)

const show = () => {
    loading.value = true
}

const hide = () => {
    loading.value = false
}

defineExpose({
    show,
    hide
})
</script>
 
<style lang="scss" scoped>
.loading {
    position: fixed;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    width: 100vw;
    height: 100vh;
    color: white;
    z-index: 9999;
    background-color: #7a777721;

    .loading_icon {
        width: 100px;
        height: 100px;
        background: #fff;
        border-radius: 10px;
        display: flex;
        justify-content: center;
        flex-direction: column;
        color: #7a7777;
        font-size: 16px;
        align-items: center;

        img {
            width: 50px;
            height: 50px;
        }

        div {
            display: inline-block;
            animation: wave-animation 1s infinite;
        }

        @keyframes wave-animation {

            0%,
            100% {
                transform: translateY(0);
            }

            50% {
                transform: translateY(-5px);
            }
        }
    }
}
</style>
 
